<%@ page language="java" import="java.util.*"  pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title>新增邀请码</title>
<link rel="stylesheet" href="resources/static/css/pintuer.css">
<link rel="stylesheet" href="resources/static/css/admin.css">
<script src="resources/static/js/jquery.min.js"></script>
<script src="resources/static/js/pintuer.js"></script>
<script type="text/javascript">
   $(function(){
     //区禁用
      $("#area").attr("disabled",true);
     
     $.post("invcode/showareainfo?type=2",function(data){
       // var jsonobjs=JSON.parse(data);
       var jsonobjs=data;
        change(jsonobjs,"city");
     },"json");
     //为2个select添加onchange事件
     
     $("#city").change(function(){
         $.post("invcode/showareainfo?type=3&citycode="+this.value,function(data){
              //var jsonobjs=JSON.parse(data);
              var jsonobjs=data;
              change(jsonobjs,"area");
         });
     });
     
   });
   function clearSelect(id){
		var $obj = $("#"+id);
		var opt = $obj.find("option").clone();
		$obj.empty();
		$obj.append(opt);
		$obj.attr("disabled",true);
	}
	function change(jsonobjs,id){
		var $obj = $("#"+id);
		var firstOpt = $obj.find("option:eq(0)").clone();
		$obj.empty();
		$obj.append(firstOpt);
		$.each(jsonobjs,function(){
			$obj.append(new Option(this.areaname,this.areacode));
		});
		$obj.attr("disabled",false);
	}
  
</script>
</head>
<body>
<div class="panel admin-panel margin-top" id="add">
  <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 新增邀请码</strong></div>
  <div class="body-content">
    <form method="get" class="form-x" action="invcode/addinvcode">
      <div class="form-group">
        <div class="label">
          <label>请选择类别：</label>
        </div>
        <div class="field">
          <div class="radio">
            <input type="radio" name="tpname" id="optionsRadios1" value="A" checked>A客户码
            <input type="radio" class="margin-big-left" name="tpname" id="optionsRadios2" value="B">B试用码
          </div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>区域：</label>
        </div>
        <div class="field">
          <select id="city" class="input w50" data-validate="required:区域">
           <option value="">--请选择--</option>
          </select>
          <select name=areacode id="area" class="input w50" data-validate="required:区域">
          <option value="">--请选择--</option>
          </select>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>生成数量：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="generatenum" data-validate="required:数量" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main " type="submit"> 生成</button>
          <button class="button bg-main margin-big-left" type="submit"> 生成并导出</button>
        </div>
      </div>
    </form>
  </div>
</div>
</body>
</html>